package com.huadao.cart_ccs.modle;

import android.content.Context;

import com.huadao.cart_ccs.base.BaseHttpModel;
import com.huadao.cart_ccs.data.bean.DeviceInfo;
import com.huadao.cart_ccs.data.source.http.Api;
import com.huadao.cart_ccs.data.source.http.HttpFunction;
import com.huadao.cart_ccs.data.source.http.RetrofitHelper;

import io.reactivex.Observable;

public class DeviceInfoModle extends BaseHttpModel {
    private Api api;

    public DeviceInfoModle(Context context) {
        api=RetrofitHelper.getInstance(context).create(Api.class);
    }

    public Observable<DeviceInfo> createAsync(String macAddress){
        DeviceInfo deviceInfo=new DeviceInfo();
        deviceInfo.setMacAddress(macAddress);
        deviceInfo.setType(2);
        return api.createDevice(deviceInfo).map(new HttpFunction());
    }

    public Observable<DeviceInfo> getDeviceById(String devId){
        return api.getDeviceById(devId).map(new HttpFunction());
    }
}
